import os
import re
+import urlparse
from .subprocess_helpers import run_sync_get_output
'TZ': 'EST5EDT'
}
+def get_mirrordir(mirrordir, keytype, uri, prefix=''):
+ assert keytype == 'git'
+ parsed = urlparse.urlsplit(uri)
+ return os.path.join(mirrordir, prefix, keytype, parsed.scheme, parsed.netloc, parsed.path[1:])
+
def find_user_chroot_path():
# We need to search PATH here manually so we correctly pick up an
# ostree install in e.g. ~/bin even though we're going to set PATH
def __init__(self):
builtins.Builtin.__init__(self)
- def _mirror_for_url(self, url):
- parsed = urlparse.urlsplit(url)
- return os.path.join(self.mirrordir, 'git', parsed.scheme, parsed.netloc, parsed.path[1:])
-
def _fixup_submodule_references(self, cwd):
submodules_status_text = run_sync_get_output(['git', 'submodule', 'status'], cwd=cwd)
submodule_status_lines = submodules_status_text.split('\n')
(sub_checksum, sub_name) = line.split(' ', 1)
sub_url = run_sync_get_output(['git', 'config', '-f', '.gitmodules',
'submodule.%s.url' % (sub_name, )], cwd=cwd)
- mirrordir = self._mirror_for_url(sub_url)
+ mirrordir = buildutil.get_mirrordir(self.mirrordir, 'git', sub_url)
run_sync(['git', 'config', 'submodule.%s.url' % (sub_name, ), 'file://' + mirrordir], cwd=cwd)
return have_submodules
(keytype, uri) = self._parse_src_key(meta['src'])
- mirror = self._mirror_for_url(uri)
+ mirror = buildutil.get_mirrordir(self.mirrordir, keytype, uri)
component_src = self._get_vcs_checkout(name, keytype, mirror, branch,
overwrite=not self.args.debug_shell)
def __init__(self):
builtins.Builtin.__init__(self)
- def _get_mirrordir(self, keytype, uri, prefix=''):
- assert keytype == 'git'
- parsed = urlparse.urlsplit(uri)
- return os.path.join(self.mirrordir, prefix, keytype, parsed.scheme, parsed.netloc, parsed.path[1:])
-
def _ensure_vcs_mirror(self, name, keytype, uri, branch):
- mirror = self._get_mirrordir(keytype, uri)
+ mirror = buildutil.get_mirrordir(self.mirrordir, keytype, uri)
tmp_mirror = mirror + '.tmp'
if os.path.isdir(tmp_mirror):
shutil.rmtree(tmp_mirror)
current_vcs_version = current_vcs_version.strip()
if current_vcs_version != last_fetch_contents:
log("last fetch %r differs from branch %r" % (last_fetch_contents, current_vcs_version))
- tmp_checkout = self._get_mirrordir(keytype, uri, prefix='_tmp-checkouts')
+ tmp_checkout = buildutil.get_mirrordir(self.mirrordir, keytype, uri, prefix='_tmp-checkouts')
if os.path.isdir(tmp_checkout):
shutil.rmtree(tmp_checkout)
parent = os.path.dirname(tmp_checkout)
name = component['name']
try:
fetch_components.index(name)
- mirrordir = self._get_mirrordir(keytype, uri)
+ mirrordir = buildutil.get_mirrordir(self.mirrordir, keytype, uri)
except ValueError, e:
mirrordir = self._ensure_vcs_mirror(name, keytype, uri, component['branch'])
revision = buildutil.get_git_version_describe(mirrordir,